home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / misc.567 < prev    next >
Text File  |  1992-02-06  |  2KB  |  56 lines

  1. {\rtf0\ansi{\fonttbl\f2\fnil Times-Roman;\f0\fmodern Courier;\f1\fswiss Helvetica;}
  2. \paperw11760
  3. \paperh7200
  4. \margl120
  5. \margr120
  6. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f2\b0\i0\ul0\fs28 rld dynamic loading\
  7. \
  8.  
  9. \fi-960\li960 Q:      The rld dynamic loader functions work in a stack oriented manner.  How can I use them to load and unload 
  10. \fi0\li0 object file
  11. \fi-960\li960 s in a more "random access" manner?\
  12.  
  13. \fi0\li0 \
  14.  
  15. \fi-960\li960 A:      (This discussion assumes you're running release 2.0.)  The stack orientation of the rld functions is intended to ensure that no symbol needed for a particular 
  16. \fi0\li0 object file
  17. \fi-960\li960  will ever be needed after it is unloaded.  If A, B and C are loaded (in that order), and C needs to reference items in B,  B cannot be unloaded without C being first, since it is last-in, first-out.\
  18. \
  19.     If your object file sets are independent of each other,  that is: C has 
  20. \b no
  21. \b0  symbols that it needs from B (in the example above), you may want to load and unload your sets in a more random fashion. If your sets are independent of each other, and you are willing to manage the references yourself, you may use a different strategy.  \
  22.     Basically, you can use rld_load to load an object file, save away the symbols you need from that object file,  and then deallocate the space that  this object file consumes when you need to.  The steps needed are below:\
  23.     \
  24. 1)      Load the object file you need using 
  25. \f0\b\fs32 rld_load().
  26. \f2\b0\fs28 \
  27. 2)     Use 
  28. \f0\b\fs32 rld_lookup()
  29. \f2\b0\fs28  repeatedly to get all of the symbols you need from this object file.\
  30. 3)    Use 
  31. \f0\b\fs32 vm_region()
  32. \f2\b0\fs28  (passing in the address of the mach header, that you got from 
  33. \f0\b\fs32 rld_load()
  34. \f2\b0\fs28  ) to find the size of the region you just loaded.\
  35. 4)    Use 
  36. \f0\b\fs32 rld_unload_all()
  37. \f2\b0\fs28  to remove this 
  38. \fi0\li0 object file
  39. \fi-960\li960  from rld's data structures.  Set deallocate_sets=0 , so that the code will remain in place after rld_unload_all() completes.  \
  40. 5)    When you are done with these routines,  you can use 
  41. \f0\b\fs32 vm_deallocate()
  42. \f2\b0\fs28  to reclaim the memory.  You will need to pass in the size you got from 
  43. \f0\b\fs32 vm_region()
  44. \f2\b0\fs28  and the header address you got from 
  45. \f0\b\fs32 rld_load().
  46. \f2\b0\fs28 \
  47.     \
  48.  
  49. \fi0\li0 Valid for 2.0\
  50.  
  51. \fi-960\li960     \
  52.  
  53. \fi0\li0 QA567\
  54. \
  55.  
  56.